package com.diit.analysisitest;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;


public class TongJiFenXiAdapter extends BaseAdapter {
    private LayoutInflater lif;
    private List<LusarBean> data;

    public TongJiFenXiAdapter(Context context, List<LusarBean> data) {
        this.data=data;
        this.lif=LayoutInflater.from(context);
    }

    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public LusarBean getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null) {
            convertView=lif.inflate(R.layout.activity_tjfx_item,null);
            holder=new ViewHolder();
            holder.nymj = (TextView)convertView.findViewById(R.id.tv_nymj);
            holder.jsmj = (TextView)convertView.findViewById(R.id.tv_jsmj);
            holder.wsymj = (TextView)convertView.findViewById(R.id.tv_wsymj);
            holder.xzqhName = (TextView)convertView.findViewById(R.id.tv_xz_xzqh_name);
            convertView.setTag(holder);

        }else {
            holder=(ViewHolder)convertView.getTag();
        }
        //获取当前对象
        LusarBean map =data.get(position);
        //赋值
        holder.nymj.setText(map.getNong()+"亩");
        holder.jsmj.setText(map.getJian()+"亩");
        holder.wsymj.setText(map.getWei()+"亩");
        holder.xzqhName.setText(map.getXzqh());

        return convertView;
    }
    public void clear(){
        this.data.clear();
    }

    public void addAll(List<LusarBean> list){
        if (data!=null) {
            this.data.addAll(list);
        }
        notifyDataSetChanged();
    }
    class ViewHolder{
    	TextView nymj;
        TextView jsmj;
        TextView wsymj;
        TextView xzqhName;

    }
}
